home *** CD-ROM | disk | FTP | other *** search
/ Games of Daze / Infomagic - Games of Daze (Summer 1995) (Disc 1 of 2).iso / x2ftp / msdos / misc / moonbas2 / world.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-11  |  19.2 KB  |  711 lines

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <time.h>
  4. #include <math.h>
  5. #include <mem.h>
  6.  
  7. #include "random.h"
  8. #include "world.h"
  9.  
  10. #define _MAKE_CRATERS
  11. #define _USE_ROUGHNESS_MAP
  12. //#define _BIZARRE_ROUGHNESS_MAP
  13. //#define _BIZARRE_ALT_MAP
  14. //#define DEBUG
  15.  
  16. //----------------------------------------------------------------------------
  17. // The maps.  Note that, in this module, the color_map array is used during
  18. // the generation of the altitude map, so in that case, it is misnamed.
  19. //----------------------------------------------------------------------------
  20.  
  21. map_t              alt_map;
  22. map_t              color_map;
  23.  
  24. //----------------------------------------------------------------------------
  25. // An internal temporary map used in generating the other maps:
  26. //----------------------------------------------------------------------------
  27.  
  28. static map_t       temp_map;
  29.  
  30. //----------------------------------------------------------------------------
  31. // Assertion code for this module:
  32. //----------------------------------------------------------------------------
  33.  
  34. #ifdef DEBUG
  35.  
  36.    static void     _Assert
  37.    (
  38.       const char * file,
  39.       unsigned     line,
  40.       const char * assertion
  41.    )
  42.    {
  43.       fflush (stdout);
  44.       fprintf ( stderr, "\nAssertion failed (%s, line %u): %s\n",
  45.                 file, line, assertion );
  46.       fflush (stderr);
  47.       abort ();
  48.    }
  49.  
  50.    #define ASSERT(f) if (f) {} else _Assert ( __FILE__, __LINE__, #f )
  51.  
  52. #else
  53.  
  54.    #define ASSERT(f)
  55.  
  56. #endif
  57.  
  58. //----------------------------------------------------------------------------
  59. // FUNCTION  rough_init
  60. //----------------------------------------------------------------------------
  61.  
  62. #ifdef _USE_ROUGHNESS_MAP
  63.  
  64. static void        rough_init
  65. (
  66.    void
  67. )
  68. {
  69.    int  x, y;
  70.  
  71.    for ( x = 0; x < map_size_x; x += 64 )
  72.    {
  73.       for ( y = 0; y < map_size_y; y += 64 )
  74.       {
  75.          color_map [x][y] = (unsigned char) (random ( 128 ) + 80);
  76.       }
  77.    }
  78. }
  79.  
  80. #endif
  81.  
  82. //----------------------------------------------------------------------------
  83. // FUNCTION  map_init
  84. //----------------------------------------------------------------------------
  85.  
  86. static void        map_init
  87. (
  88.    void
  89. )
  90. {
  91.    int  x, y;
  92.  
  93.    for ( x = 0; x < map_size_x; x += 64 )
  94.    {
  95.       for ( y = 0; y < map_size_y; y += 64 )
  96.       {
  97.          color_map [x][y] = (unsigned char) random ( 256 );
  98.       }
  99.    }
  100. }
  101.  
  102. //----------------------------------------------------------------------------
  103. // FUNCTION  flat_area
  104. //----------------------------------------------------------------------------
  105.  
  106. static void        flat_area
  107. (
  108.    int             map_x,
  109.    int             map_y,
  110.    int             size_x,
  111.    int             size_y,
  112.    int             height_offset = 0
  113. )
  114. {
  115.    int             height;
  116.    int             x, y;
  117.  
  118.    // First get the average height of the original rectangular region.
  119.  
  120.    height = 0;
  121.  
  122.    for ( x = 0; x < size_x; ++ x )
  123.    {
  124.       for ( y = 0; y < size_y; ++ y )
  125.       {
  126.          height +=
  127.             (int) alt_map [(x+map_x) & clip_mask_x][(y+map_y) & clip_mask_y];
  128.       }
  129.    }
  130.  
  131.    height /= size_x * size_y;
  132.  
  133.    // Offset from the average height.
  134.  
  135.    height += height_offset;
  136.    if      ( height < min_alt   )  height = min_alt;
  137.    else if ( height > max_alt-1 )  height = max_alt - 1;
  138.  
  139.    // Put in the landing pad.
  140.  
  141.    for ( x = 0; x < size_x; ++ x )
  142.    {
  143.       for ( y = 0; y < size_y; ++ y )
  144.       {
  145.          alt_map [(x+map_x) & clip_mask_x][(y+map_y) & clip_mask_y] =
  146.             (unsigned char) (height + random (2));
  147.       }
  148.    }
  149. }
  150.  
  151. //----------------------------------------------------------------------------
  152. // FUNCTION  quonset_hut
  153. //----------------------------------------------------------------------------
  154. // These quonset huts run parallel to the Y axis.
  155. //----------------------------------------------------------------------------
  156.  
  157. static void        quonset_hut
  158. (
  159.    int             map_x,
  160.    int             map_y,
  161.    int             size_y
  162. )
  163. {
  164.    int             average;
  165.    int             x, y;
  166.  
  167.    const           radius = 4;
  168.  
  169.    // First get the average height of the original region.
  170.  
  171.    average = 0;
  172.  
  173.    for ( x = 0; x < radius * 2; ++ x )
  174.    {
  175.       for ( y = 0; y < size_y; ++ y )
  176.       {
  177.          average +=
  178.             alt_map [(x+map_x) & clip_mask_x][(y+map_y) & clip_mask_y];
  179.       }
  180.    }
  181.  
  182.    average /= size_y * radius * 2;
  183.  
  184.    // Bury the quonset hut a bit.
  185.  
  186.    average -= scale_area / scale_height;
  187.  
  188.    // Build the hut.
  189.  
  190.    int r_squared = radius * radius;
  191.  
  192.    for ( x = 0; x < radius * 2; ++ x )
  193.    {
  194.       int height =
  195.          (int) sqrt ( (double) (r_squared - (x-radius)*(x-radius) + 1) );
  196.       height *= (scale_area / scale_height);
  197.       height += average;
  198.       if ( height > max_alt ) height = max_alt;
  199.  
  200.       for ( y = 0; y < size_y; ++ y )
  201.       {
  202.          alt_map [(x+map_x) & clip_mask_x][(y+map_y) & clip_mask_y] =
  203.             (unsigned char) height;
  204.       }
  205.    }
  206. }
  207.  
  208. //----------------------------------------------------------------------------
  209. // FUNCTION  generate_roughness_map
  210. //----------------------------------------------------------------------------
  211.  
  212. #ifdef _USE_ROUGHNESS_MAP
  213.  
  214. static void        generate_roughness_map
  215. (
  216.    void
  217. )
  218. {
  219.    printf ( "  Roughness map:    0 %%" );
  220.  
  221.    rough_init ();
  222.  
  223.    int counter = 0;
  224.    int which   = 0;
  225.  
  226.    for ( int square_size = 64; square_size > 1; square_size /= 2 )
  227.    {
  228.       for ( int x1 = 0; x1 < map_size_x; x1 += square_size )
  229.       {
  230.          for ( int y1 = 0; y1 < map_size_y; y1 += square_size )
  231.          {
  232.             // Get the four influential points.
  233.  
  234.             int x2 = (x1 + square_size) & clip_mask_x;
  235.             int y2 = (y1 + square_size) & clip_mask_y;
  236.  
  237.             int i1, i2, i3, i4;
  238.  
  239.             if ( which == 0 )
  240.             {
  241.                i1 = color_map [x1][y1];
  242.                i2 = color_map [x2][y1];
  243.                i3 = color_map [x1][y2];
  244.                i4 = color_map [x2][y2];
  245.             }
  246.             else
  247.             {
  248.                i1 = alt_map [x1][y1];
  249.                i2 = alt_map [x2][y1];
  250.                i3 = alt_map [x1][y2];
  251.                i4 = alt_map [x2][y2];
  252.             }
  253.  
  254.             // Obtain new points by averaging the influential points.
  255.  
  256.             int p1 = ((i1 * 9) + (i2 * 3) + (i3 * 3) + (i4)) / 16;
  257.             int p2 = ((i1 * 3) + (i2 * 9) + (i3) + (i4 * 3)) / 16;
  258.             int p3 = ((i1 * 3) + (i2) + (i3 * 9) + (i4 * 3)) / 16;
  259.             int p4 = ((i1) + (i2 * 3) + (i3 * 3) + (i4 * 9)) / 16;
  260.  
  261.             // Add a random offset to each new point.
  262.  
  263.             int random_center = square_size;
  264.             int random_range  = random_center * 2;
  265.  
  266.             #ifdef _BIZARRE_ROUGHNESS_MAP
  267.  
  268.                p1 += random (random_center) + random_range - (max_alt - p1)/6;
  269.                p2 += random (random_center) + random_range - (max_alt - p2)/6;
  270.                p3 += random (random_center) + random_range - (max_alt - p3)/6;
  271.                p4 += random (random_center) + random_range - (max_alt - p4)/6;
  272.  
  273.             #else
  274.  
  275.                p1 += random (random_range) - random_center;
  276.                p2 += random (random_range) - random_center;
  277.                p3 += random (random_range) - random_center;
  278.                p4 += random (random_range) - random_center;
  279.  
  280.             #endif
  281.  
  282.             // Boundary check the altitudes.  Under the normal condition,
  283.             // altitudes that are out of range will be "reflected" back into
  284.             // the allowable range.  Under the bizarre condition, we do
  285.             // something bizarre!
  286.  
  287.             #ifdef _BIZARRE_ROUGHNESS_MAP
  288.  
  289.                p1 = (p1 < min_alt) ? max_alt + p1 + 1 : p1;
  290.                p2 = (p2 < min_alt) ? max_alt + p2 + 1 : p2;
  291.                p3 = (p3 < min_alt) ? max_alt + p3 + 1 : p3;
  292.                p4 = (p4 < min_alt) ? max_alt + p4 + 1 : p4;
  293.  
  294.                p1 = (p1 > max_alt) ? (p1 % (max_alt+1)) : p1;
  295.                p2 = (p2 > max_alt) ? (p2 % (max_alt+1)) : p2;
  296.                p3 = (p3 > max_alt) ? (p3 % (max_alt+1)) : p3;
  297.                p4 = (p4 > max_alt) ? (p4 % (max_alt+1)) : p4;
  298.  
  299.             #else
  300.  
  301.                p1 = (p1 < min_alt) ? (min_alt - p1) + min_alt : p1;
  302.                p2 = (p2 < min_alt) ? (min_alt - p2) + min_alt : p2;
  303.                p3 = (p3 < min_alt) ? (min_alt - p3) + min_alt : p3;
  304.                p4 = (p4 < min_alt) ? (min_alt - p4) + min_alt : p4;
  305.  
  306.                p1 = (p1 > max_alt) ? (max_alt - p1) + max_alt : p1;
  307.                p2 = (p2 > max_alt) ? (max_alt - p2) + max_alt : p2;
  308.                p3 = (p3 > max_alt) ? (max_alt - p3) + max_alt : p3;
  309.                p4 = (p4 > max_alt) ? (max_alt - p4) + max_alt : p4;
  310.  
  311.             #endif
  312.  
  313.             // Write out the generated points.
  314.  
  315.             x2 = (x1 + square_size/2) & clip_mask_x;
  316.             y2 = (y1 + square_size/2) & clip_mask_y;
  317.  
  318.             if ( which == 0 )
  319.             {
  320.                alt_map   [x1][y1] = (unsigned char) p1;
  321.                alt_map   [x2][y1] = (unsigned char) p2;
  322.                alt_map   [x1][y2] = (unsigned char) p3;
  323.                alt_map   [x2][y2] = (unsigned char) p4;
  324.             }
  325.             else
  326.             {
  327.                color_map [x1][y1] = (unsigned char) p1;
  328.                color_map [x2][y1] = (unsigned char) p2;
  329.                color_map [x1][y2] = (unsigned char) p3;
  330.                color_map [x2][y2] = (unsigned char) p4;
  331.             }
  332.  
  333.             counter += 100;
  334.          }
  335.  
  336.          int percent_done = (int) ( counter / 87360 );
  337.  
  338.          printf ( "\b\b\b\b\b%3d %%", percent_done );
  339.       }
  340.  
  341.       which = (which == 0) ? 1 : 0;
  342.    }
  343.  
  344.    if ( which == 0 )
  345.    {
  346.       memcpy ( temp_map, color_map, sizeof (temp_map) );
  347.    }
  348.    else
  349.    {
  350.       memcpy ( temp_map, alt_map, sizeof (temp_map) );
  351.    }
  352.  
  353.    printf ( "\b\b\b\b\bdone \n" );
  354. }
  355.  
  356. #endif
  357.  
  358. //----------------------------------------------------------------------------
  359. // FUNCTION  generate_alt_map
  360. //----------------------------------------------------------------------------
  361.  
  362. static void        generate_alt_map
  363. (
  364.    void
  365. )
  366. {
  367.    #ifdef _USE_ROUGHNESS_MAP
  368.  
  369.       generate_roughness_map ();
  370.  
  371.    #endif
  372.  
  373.    printf ( "  Altitude map:     0 %%" );
  374.    fflush ( stdout );
  375.  
  376.    map_init ();
  377.  
  378.    int which   = 0;
  379.    int counter = 0;
  380.  
  381.    for ( int square_size = 64; square_size > 1; square_size /= 2 )
  382.    {
  383.       #ifdef _MAKE_CRATERS
  384.  
  385.          if ( square_size == 8 || square_size == 4 )
  386.          {
  387.             for ( int i = 0; i < map_size_x * 3; ++ i )
  388.             {
  389.                if ( which == 0 )
  390.                   color_map [random (map_size_x)][random (map_size_y)]
  391.                      = (unsigned char) random (32);
  392.                else
  393.                   alt_map [random (map_size_x)][random (map_size_y)]
  394.                      = (unsigned char) random (32);
  395.             }
  396.          }
  397.  
  398.       #endif
  399.  
  400.       // Make pseudo-valley floors.
  401.  
  402.       if ( square_size == 2 )
  403.       {
  404.          for ( int x = 0; x < map_size_x; ++ x )
  405.          {
  406.             for ( int y = 0; y < map_size_y; ++ y )
  407.             {
  408.                const cutoff_point = (max_alt+1) / 4;
  409.  
  410.                if ( alt_map [x][y] < cutoff_point )
  411.                {
  412.                   alt_map [x][y] =
  413.                      (unsigned char) (cutoff_point - alt_map [x][y]/2);
  414.                }
  415.             }
  416.          }
  417.       }
  418.  
  419.       for ( int x1 = 0; x1 < map_size_x; x1 += square_size )
  420.       {
  421.          for ( int y1 = 0; y1 < map_size_y; y1 += square_size )
  422.          {
  423.             // Get the four influential points.
  424.  
  425.             int x2 = (x1 + square_size) & clip_mask_x;
  426.             int y2 = (y1 + square_size) & clip_mask_y;
  427.  
  428.             int i1, i2, i3, i4;
  429.  
  430.             if ( which == 0 )
  431.             {
  432.                i1 = color_map [x1][y1];
  433.                i2 = color_map [x2][y1];
  434.                i3 = color_map [x1][y2];
  435.                i4 = color_map [x2][y2];
  436.             }
  437.             else
  438.             {
  439.                i1 = alt_map [x1][y1];
  440.                i2 = alt_map [x2][y1];
  441.                i3 = alt_map [x1][y2];
  442.                i4 = alt_map [x2][y2];
  443.             }
  444.  
  445.             // Obtain new points by averaging the influential points.
  446.  
  447.             int p1 = ((i1 * 9) + (i2 * 3) + (i3 * 3) + (i4)) / 16;
  448.             int p2 = ((i1 * 3) + (i2 * 9) + (i3) + (i4 * 3)) / 16;
  449.             int p3 = ((i1 * 3) + (i2) + (i3 * 9) + (i4 * 3)) / 16;
  450.             int p4 = ((i1) + (i2 * 3) + (i3 * 3) + (i4 * 9)) / 16;
  451.  
  452.             // Add a random offset to each new point.
  453.  
  454.             #ifdef _USE_ROUGHNESS_MAP
  455.                int random_center = square_size * temp_map [x1][y1] / 84;
  456.             #else
  457.                int random_center = square_size * 2;
  458.             #endif
  459.  
  460.             int random_range = random_center * 2;
  461.  
  462.             #ifdef _BIZARRE_ALT_MAP
  463.  
  464.                p1 += ( random ( random_range ) - random_center + p1/4 );
  465.                p2 += ( random ( random_range ) - random_center + p2/4 );
  466.                p3 += ( random ( random_range ) - random_center + p3/4 );
  467.                p4 += ( random ( random_range ) - random_center + p4/4 );
  468.  
  469.             #else
  470.  
  471.                p1 += ( random ( random_range ) - random_center );
  472.                p2 += ( random ( random_range ) - random_center );
  473.                p3 += ( random ( random_range ) - random_center );
  474.                p4 += ( random ( random_range ) - random_center );
  475.  
  476.             #endif
  477.  
  478.             // Boundary checking
  479.  
  480.             p1 = (p1 < min_alt) ? (min_alt - p1) + min_alt : p1;
  481.             p2 = (p2 < min_alt) ? (min_alt - p2) + min_alt : p2;
  482.             p3 = (p3 < min_alt) ? (min_alt - p3) + min_alt : p3;
  483.             p4 = (p4 < min_alt) ? (min_alt - p4) + min_alt : p4;
  484.  
  485.             #ifdef _BIZARRE_ALT_MAP
  486.  
  487.                p1 = (p1 > max_alt) ? (p1 - (max_alt+1)) : p1;
  488.                p2 = (p2 > max_alt) ? (p2 - (max_alt+1)) : p2;
  489.                p3 = (p3 > max_alt) ? (p3 - (max_alt+1)) : p3;
  490.                p4 = (p4 > max_alt) ? (p4 - (max_alt+1)) : p4;
  491.  
  492.             #else
  493.  
  494.                p1 = (p1 > max_alt) ? (max_alt - p1) + max_alt : p1;
  495.                p2 = (p2 > max_alt) ? (max_alt - p2) + max_alt : p2;
  496.                p3 = (p3 > max_alt) ? (max_alt - p3) + max_alt : p3;
  497.                p4 = (p4 > max_alt) ? (max_alt - p4) + max_alt : p4;
  498.  
  499.             #endif
  500.  
  501.             // Write out the generated points.
  502.  
  503.             x2 = (x1 + square_size/2) & clip_mask_x;
  504.             y2 = (y1 + square_size/2) & clip_mask_y;
  505.  
  506.             if ( which == 0 )
  507.             {
  508.                alt_map [x1][y1]   = (unsigned char) p1;
  509.                alt_map [x2][y1]   = (unsigned char) p2;
  510.                alt_map [x1][y2]   = (unsigned char) p3;
  511.                alt_map [x2][y2]   = (unsigned char) p4;
  512.             }
  513.             else
  514.             {
  515.                color_map [x1][y1] = (unsigned char) p1;
  516.                color_map [x2][y1] = (unsigned char) p2;
  517.                color_map [x1][y2] = (unsigned char) p3;
  518.                color_map [x2][y2] = (unsigned char) p4;
  519.             }
  520.  
  521.             counter += 100;
  522.          }
  523.  
  524.          int percent_done = (int) ( counter / 87360 );
  525.  
  526.          printf ( "\b\b\b\b\b%3d %%", percent_done );
  527.       }
  528.  
  529.       which = (which == 0) ? 1 : 0;
  530.    }
  531.  
  532.    if ( which == 0 )
  533.    {
  534.       memcpy ( alt_map, color_map, map_size_x * map_size_y );
  535.    }
  536.  
  537.    // Create some man-made features in the landscape.
  538.  
  539.    flat_area   ( 0,  0,  20, 20 );
  540.    quonset_hut ( 0,  20, 24 );
  541.  
  542.    // We're done!
  543.  
  544.    printf ( "\b\b\b\b\bdone \n" );
  545.    fflush ( stdout );
  546. }
  547.  
  548. //----------------------------------------------------------------------------
  549. // FUNCTION  calc_color_map
  550. //----------------------------------------------------------------------------
  551.  
  552. static void        calc_color_map
  553. (
  554.    void
  555. )
  556. {
  557.    int x,  y;
  558.    int color;
  559.    int percent_done;
  560.  
  561.    int * shadow;
  562.  
  563.    shadow = (int *) calloc ( map_size_y, sizeof (int) );
  564.    ASSERT ( shadow != NULL );
  565.  
  566.    printf ( "  Shading map:      0 %%" );
  567.    fflush ( stdout );
  568.  
  569.    for ( x = 0; x < map_size_x; ++ x )
  570.    {
  571.       for ( y = 0; y < map_size_y; ++ y )
  572.       {
  573.          int slope = alt_map [x][y] - alt_map [(x-1)&clip_mask_x][y];
  574.  
  575.          slope *= 2;
  576.          slope += 40;
  577.  
  578.          if ( slope < 0  ) slope = 0;
  579.          if ( slope > 63 ) slope = 63;
  580.  
  581.          color = slope + 1;
  582.  
  583.          color_map [x][y] = (unsigned char) color;
  584.       }
  585.  
  586.       percent_done = x * 24 / map_size_x;
  587.  
  588.       printf ( "\b\b\b\b\b%3d %%", percent_done );
  589.    }
  590.  
  591.    // Cast shadows.
  592.  
  593.    for ( y = 0; y < map_size_y; ++ y )
  594.    {
  595.       shadow [y] = (int) alt_map [0][y];
  596.    }
  597.  
  598.    for ( x = 1; x < map_size_x; ++ x )
  599.    {
  600.       for ( y = 0; y < map_size_y; ++ y )
  601.       {
  602.          shadow [y] -= 3;
  603.          if ( shadow [y] < 0 )  shadow [y] = 0;
  604.  
  605.          int height = (int) alt_map [x][y];
  606.  
  607.          if ( height >= shadow [y] )
  608.          {
  609.             shadow [y] = height;
  610.  
  611.             temp_map [x][y] = 0;
  612.          }
  613.          else
  614.          {
  615.             temp_map [x][y] = 1;
  616.          }
  617.       }
  618.  
  619.       percent_done = x * 23 / map_size_x + 24;
  620.  
  621.       printf ( "\b\b\b\b\b%3d %%", percent_done );
  622.    }
  623.  
  624.    for ( x = 0; x < 128; ++ x )
  625.    {
  626.       for ( y = 0; y < map_size_y; ++ y )
  627.       {
  628.          shadow [y] -= 3;
  629.          if ( shadow [y] < 0 )  shadow [y] = 0;
  630.  
  631.          int height = (int) alt_map [x][y];
  632.  
  633.          if ( height >= shadow [y] )
  634.          {
  635.             shadow [y] = height;
  636.  
  637.             temp_map [x][y] = 0;
  638.          }
  639.          else
  640.          {
  641.             temp_map [x][y] = 1;
  642.          }
  643.       }
  644.  
  645.       percent_done = x * 6 / map_size_x + 47;
  646.  
  647.       printf ( "\b\b\b\b\b%3d %%", percent_done );
  648.    }
  649.  
  650.    for ( x = 0; x < map_size_x; ++ x )
  651.    {
  652.       for ( y = 0; y < map_size_y; ++ y )
  653.       {
  654.          if ( temp_map [x][y] )
  655.          {
  656.             int color = (int) color_map [x][y];
  657.             color -= 18;
  658.             if ( color < 1 )
  659.                color = 1;
  660.             color_map [x][y] = (unsigned char) color;
  661.          }
  662.       }
  663.  
  664.       percent_done = x * 23 / map_size_x + 53;
  665.  
  666.       printf ( "\b\b\b\b\b%3d %%", percent_done );
  667.    }
  668.  
  669.    // Average the map colors to make the map appear smoother.
  670.  
  671.    for ( x = 0; x < map_size_x; ++ x )
  672.    {
  673.       for ( y = 0; y < map_size_y; ++ y )
  674.       {
  675.          color  = 6 * color_map [x][y];
  676.          color += 4 * color_map [(x+1) & clip_mask_x][y];
  677.          color += 4 * color_map [x][(y+1) & clip_mask_y];
  678.          color += 2 * color_map [(x+1) & clip_mask_x][(y+1) & clip_mask_y];
  679.  
  680.          color /= 16;
  681.  
  682.          color_map [x][y] = (unsigned char) color;
  683.       }
  684.  
  685.       percent_done = x * 24 / map_size_x + 76;
  686.  
  687.       printf ( "\b\b\b\b\b%3d %%", percent_done );
  688.    }
  689.  
  690.    free (shadow);
  691.  
  692.    printf ( "\b\b\b\b\bdone \n" );
  693.    fflush ( stdout );
  694. }
  695.  
  696. //----------------------------------------------------------------------------
  697. // FUNCTION  WORLD_generate
  698. //----------------------------------------------------------------------------
  699.  
  700. void               WORLD_generate
  701. (
  702.    void
  703. )
  704. {
  705.    printf ( "\nGenerating the moonscape...\n\n" );
  706.  
  707.    randomize        ();
  708.    generate_alt_map ();
  709.    calc_color_map   ();
  710. }
  711.